package com.ljc;

/**
 * @author clj
 * @date 2023/6/1
 * @desc
 */
public class E168ExcelSheetColumnTitle {

    public static String convertToTitle(int n) {
        StringBuilder sb = new StringBuilder();
        while (n > 0) {
            int c = n % 26;
            System.out.println("n%26取余数得c：" + c);
            if(c == 0){
                c = 26;
                n -= 1;
            }
            System.out.println("（'A' + c - 1)）： " + (char) ('A' + c - 1));

            sb.insert(0, (char) ('A' + c - 1));
            n /= 26;
            System.out.println("n/26取整得n：" + n);
            System.out.println("========");
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        int n = 170;
        System.out.println(convertToTitle(n));
    }

}
